package advanced;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;

import org.junit.Test;

public class Test2 {
	@Test
	public void test1() throws Exception{
		Writer writer=new FileWriter("fdata.txt");
		writer.write('中');
		writer.close();
	}
	
	@Test
	public void test2() throws Exception{
		Reader reader=new FileReader("john.txt");
		char c=(char)reader.read();
		System.out.println(c);
		reader.close();
	}
	
	@Test
	public void test3() throws Exception{
		BufferedReader reader=new BufferedReader(new FileReader("fdata1.txt"));
		String line=null;
		while((line=reader.readLine())!=null){
			System.out.println(line);
		}
		reader.close();
	}
	
	@Test
	public void test4() throws Exception{
		InputStream in=new FileInputStream("fdata1.txt");
		BufferedReader reader=new BufferedReader(new InputStreamReader(in,"UTF-16BE"));
		String line=null;
		while((line=reader.readLine())!=null){
			System.out.println(line);
		}
		reader.close();
	}
	
	
	
	
	
	
	
	
	
	
	
	
	public static void main(String[] args) throws Exception{
		
	}

}
